home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 460_01 / YACL0160.ZIP / uidemo / visobjs / main.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-18  |  3.2 KB  |  113 lines

  1.  
  2. // A dialog with "duelling" StringViews
  3. //
  4. // M. A. Sridhar
  5. // May 13, 1995
  6.  
  7. #include "ui/applic.h"
  8. #include "ui/composit.h"
  9. #include "ui/strseq.h"
  10. #include "ui/textedit.h"
  11.  
  12.  
  13. // ======================== Main program ===========================
  14.  
  15.  
  16.  
  17. UI_RectangleStruct Dialog_shape = {
  18. //---- YACLDlgEditorBegin Dialog shape ------
  19.     40, 40, 481, 475
  20. //---- YACLDlgEditorEnd Dialog shape ------
  21. };
  22.  
  23. enum {
  24.     ID_STRVIEW = 101,
  25.     ID_COMBO,
  26.     ID_STRED,
  27.     ID_LABEL1,
  28.     ID_LABEL2,
  29.     ID_LABEL3,
  30.     ID_TOGGLE,
  31.     ID_XRTGL,
  32.     ID_TEXTED
  33. };
  34.  
  35. UI_ViewDescriptor Dialog_dlgDesc [] = {
  36. //---- YACLDlgEditorBegin Dialog items ------
  37. {View_Label          , ID_LABEL1   , 15, 13,  125,   30, FALSE, "StringView:"},
  38. {View_StringViewSingle, ID_STRVIEW,  30, 45,  280,  90, TRUE, ""},
  39. {View_Label          , ID_LABEL2   , 20,  143,  125,   30, FALSE, "ComboBox:"},
  40. {View_ComboBox       , ID_COMBO    , 30, 175, 280,   75, TRUE, ""},
  41. {View_Label          , ID_LABEL3   , 24,224,  125, 30, FALSE, "StringEditor:"},
  42. {View_StringEditor   , ID_STRED    ,  165,  223,  125,   30, TRUE, ""},
  43. {View_TextView       , ID_TEXTED   ,   20,  255,  400,  150, TRUE, ""},
  44. // {View_PushButton     , 56          ,  138,  275, 75,   30, TRUE, "Ok"},
  45. // {View_PushButton     , 57          ,  261,  274, 75,   30, TRUE, "Cancel"},
  46. {View_ToggleButton   , ID_TOGGLE   ,  320,   49, 126, 30, TRUE, "Toggle"},
  47. {View_ExOrToggleButton,ID_XRTGL     , 320,   91, 126, 30, TRUE, "ExOr Toggle"},
  48. {View_None, 0, 0}
  49. //---- YACLDlgEditorEnd Dialog items ------
  50. };
  51.  
  52.  
  53.  
  54.  
  55.  
  56. char* Data [] = {
  57.     "A study in scarlet",
  58.     "The sign of four",
  59.     "The valley of fear",
  60.     "The hound of the Baskervilles",
  61.     "The speckled band",
  62.     "The \"Gloria Scott\"",
  63.     "The Musgrave ritual",
  64.     "The resident patient",
  65.     "The Greek interpreter",
  66.     NULL
  67. };
  68.  
  69.  
  70. char* Message = "This app shows how to set VisualObject colors.";
  71.  
  72. int UI_Application::Main (int, char* [])
  73. {
  74.     UI_CompositeVObject* root = new UI_CompositeVObject
  75.         (NULL, Dialog_dlgDesc, FALSE, Dialog_shape);
  76.     root->Title() = "YACL VisualObject Colors Demo";
  77.     MakeTopWindow (root);
  78.  
  79.     root->Background (UIColor_LightGray);
  80.     (*root)[ID_LABEL1]->Background (UIColor_LightGray);
  81.     (*root)[ID_LABEL2]->Background (UIColor_LightGray);
  82.     (*root)[ID_LABEL3]->Background (UIColor_LightGray);
  83.     (*root)[ID_TOGGLE]->Background (UIColor_LightGray);
  84.     (*root)[ID_XRTGL]->Background (UIColor_LightGray);
  85.     (*root)[ID_COMBO]->Background (UIColor_LightGray);
  86.     (*root)[ID_STRED]->Background (UIColor_MediumGray);
  87.     (*root)[ID_STRVIEW]->Background (UIColor_LightGray);
  88.  
  89.     UI_TextEditor* edit = (UI_TextEditor*) (*root)[ID_TEXTED];
  90.     edit->Background (UIColor_DarkGray);
  91.     edit->Foreground (UIColor_White);
  92.     ((CL_String&) edit->Model()) = Message;
  93.  
  94.     (*root)[ID_LABEL1]->Foreground (UIColor_Red);
  95.     (*root)[ID_LABEL2]->Foreground (UIColor_Green);
  96.     (*root)[ID_LABEL3]->Foreground (UIColor_Blue);
  97.  
  98.     UI_StringSequence& comboSq = (UI_StringSequence&)
  99.         ((*root)[ID_COMBO]->Model());
  100.     UI_StringSequence& listSq = (UI_StringSequence&)
  101.         ((*root)[ID_STRVIEW]->Model());
  102.     short i;
  103.     for (i = 0; Data[i] != NULL; i++) {
  104.         comboSq.Add (Data[i]);
  105.         listSq.Add (Data[i]);
  106.     }
  107.  
  108.     Run();
  109.     return 0;
  110. }
  111.  
  112.  
  113.